﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace GabageFactory.Models
{
    public class TailingpondDitchReposity : Reposity
    {
        public tailingpond_daily_ditch_info GetDailyDitchInfo(int tailingpondId, DateTime date)
        {
            var dailyDitch = from s in _dataContext.tailingpond_daily_ditch_infos
                             where tailingpondId == s.tailingpond_id && s.date == date.Date
                             select s;

            if (dailyDitch != null && dailyDitch.Count() > 0)
            {
                return dailyDitch.First();
            }
            else
            {
                return null;
            }
        }

        public tailingpond_daily_ditch_info CreateDailyDitch(tailingpond_daily_ditch_info dailyDitch)
        {
            _dataContext.tailingpond_daily_ditch_infos.InsertOnSubmit(dailyDitch);
            SubmitChanges();
            return dailyDitch;
        }

        public bool DeleteDailyDitch(tailingpond_daily_ditch_info dailyDitch)
        {
            _dataContext.tailingpond_daily_ditch_infos.DeleteOnSubmit(dailyDitch);
            return true;
        }
    }
}